package cn.ronghuanet.car.doc;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 文档对象
 */
@Document(indexName = "ronghua_car",type = "carDoc")
@Data
public class CarDoc {

    @Id
    private Long id;

    @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
    private String title;

    @Field(type = FieldType.Keyword)
    private String cover;

    @Field(type = FieldType.Double)
    private BigDecimal saleprice;

    @Field(type = FieldType.Double)
    private BigDecimal costprice;

    @Field(type = FieldType.Integer)
    private Integer isnew;

    @Field(type = FieldType.Date)
    private Date reigstertime;

    @Field(type = FieldType.Double)
    private Double mileage;

    @Field(type = FieldType.Long)
    private Long shopId;

    //@Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
    @MultiField(
            mainField = @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart"),
            otherFields = {@InnerField(suffix = "keyword",type = FieldType.Keyword)}
    )
    private String shopName;

    @Field(type = FieldType.Keyword)
    private String shopAddress;

    // 店铺地址的经纬度,用于后续做店铺举例排序用的
    @GeoPointField
    private GeoPoint shopPoint;

    @Field(type = FieldType.Date)
    private Date onsaletime;

    @Field(type = FieldType.Integer)
    private Integer costeffective;

    @Field(type = FieldType.Integer)
    private Integer rushsale;

    @Field(type = FieldType.Integer)
    private Integer quasinewcar;

    @Field(type = FieldType.Integer)
    private Integer transitivecountry;

    @Field(type = FieldType.Long)
    private Long typeId;

    //@Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
    @MultiField(
            mainField = @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart"),
            otherFields = {@InnerField(suffix = "keyword",type = FieldType.Keyword)}
    )
    private String typeName;

    @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
    private String carInfo;

    private String reigstertimeStr; // 上牌时间的字符串类型,用来处理前端格式的
}
